/**
 * createby : JinxLbj
 * date : 2018/8/15
 * desc : Netty服务接口实现类
 **/

package com.example.demo.netty.service.impl;

import com.example.demo.netty.SimpleChatServerHandler;
import com.example.demo.netty.service.NettyService;
import io.netty.channel.group.ChannelGroup;
import org.springframework.stereotype.Service;

import java.nio.channels.Channel;

@Service
public class NettyServiceImpl implements NettyService {

    @Override
    public void sendMessageToEveryone(String projectName, String message) {
        ChannelGroup channels = SimpleChatServerHandler.getChannels();
        channels.writeAndFlush("[" + projectName + "] " + message);
    }

}
